"ui";
db = sqlite.open("./data.db", {
    version: 1
}, {
    onOpen: function(db) {
        // 数据库打开时，执行创建数据库表的语句
        db.execSQL(
            //创建当前密码表
            "CREATE TABLE IF NOT EXISTS password(" +
            "`id` INTEGER PRIMARY KEY AUTOINCREMENT, " +
            "`pd` TEXT NOT NULL" +
            ");"
        );
    }
})
pd = db.rawQuery("SELECT * FROM password", null).single()["pd"];
inputwidth =
    ui.layout(
        <frame>
        <vertical bg="file://res/躲避.jpg">
            <vertical layout_weight="8">
                <horizontal background="#55000000">
                    <vertical id="daily" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_book_black_48dp" tint="#FFFFFF" />
                        <text text="日常营销" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="direct" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_motorcycle_black_48dp" tint="#FFFFFF" />
                        <text text="直管客户" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="vip" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_flight_takeoff_black_48dp" tint="#FFFFFF" />
                        <text text="贵宾客户" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="android" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_android_black_48dp" tint="#FFFFFF" />
                        <text text="检查安卓" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                </horizontal>
                <horizontal background="#55000000">
                    <vertical id="test_daily" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_face_black_48dp" tint="#FFFFFF" />
                        <text text="测试日常" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="old_direct" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_perm_contact_calendar_black_48dp" tint="#FFFFFF" />
                        <text text="旧版直管" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="old_vip" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_filter_vintage_black_48dp" tint="#FFFFFF" />
                        <text text="旧版贵宾" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="autoforservice" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_bubble_chart_black_48dp" tint="#FFFFFF" />
                        <text text="检查服务" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                </horizontal>
                <horizontal background="#55000000">
                    <vertical id="spec_vip" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_gavel_black_48dp" tint="#FFFFFF" />
                        <text text="特殊贵宾" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="spec_direct" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_brightness_7_black_48dp" tint="#FFFFFF" />
                        <text text="特殊直管" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="stable_vip" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_colorize_black_48dp" tint="#FFFFFF" />
                        <text text="稳定贵宾" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                    <vertical id="stable_direct" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_extension_black_48dp" tint="#FFFFFF" />
                        <text text="稳定直管" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                </horizontal>
            </vertical>
            <card bg="#55000000" layout_weight="1">
                <horizontal layout_alignParentBottom="true">
                    <text text="当前密码:" textColor="#ffffff" gravity="center" layout_weight="1" textSize="20" />
                    <input w="-1" textStyle="bold" text="{{ pd }}" id="pd" textColor="#ffffff" layout_weight="4" />
                    <vertical id="save" clickable="true" bg="?android:attr/selectableItemBackground" layout_weight="1" >
                        <img id="bootimg" padding="0 0 0 0" src="@drawable/ic_save_black_48dp" tint="#FFFFFF" />
                        <text text="保存" margin="0 0 0 0" textStyle="bold" textColor="#FFFFFF" gravity="center" />
                    </vertical>
                </horizontal>
            </card>
        </vertical>
    </frame>
    )
ui.statusBarColor("#ff000000")
ui.pd.on("long_click", () => {
    ui.pd.setText("")
})
ui.save.on("click", () => {
    db.update("password", {
        pd: ui.pd.text()
    }, "id = ?", ["1"])
    toastLog("｡◕‿◕｡修改密码为:" + ui.pd.text())
})
ui.daily.on("click", () => {
    engines.execScriptFile("./每日.js");
})
ui.vip.on("click", () => {
    engines.execScriptFile("./迅捷贵宾.js");
})
ui.direct.on("click", () => {
    engines.execScriptFile("./迅捷直管.js");
})
ui.test_daily.on("click", () => {
    engines.execScriptFile("./测试每日.js");
})
ui.old_vip.on("click", () => {
    engines.execScriptFile("./旧版贵宾.js");
})
ui.old_direct.on("click", () => {
    engines.execScriptFile("./旧版直管.js");
})
ui.spec_vip.on("click", () => {
    engines.execScriptFile("./特殊贵宾.js");
})
ui.spec_direct.on("click", () => {
    engines.execScriptFile("./特殊直管.js");
})
ui.stable_vip.on("click", () => {
    engines.execScriptFile("./稳定贵宾.js");
})
ui.stable_direct.on("click", () => {
    engines.execScriptFile("./稳定直管.js");
})
ui.android.on("click", () => {
    toastLog("安卓" + device.release);
})
ui.autoforservice.on("click", () => {
    app.startActivity({
        action: "android.settings.ACCESSIBILITY_SETTINGS"
    });
    toastLog("请给我无障碍服务权限");
})